import { getFileGroupTree } from '@/api/develop/file'
/**
 * 获取文件管理树-只含文件组
 */
const treeGroupData_ = ref([
  {
    name: '根节点',
    id: '0',
    children: []
  }
])

export function useGroupTree() {
  if (treeGroupData_.value[0].children.length == 0) {
    // 没有时重新请求
    reFreshTreeData()
  }

  function reFreshTreeData() {
    getFileGroupTree({}).then((res) => {
      treeGroupData_.value[0].children = res
    })
  }
  return {
    treeGroupData: treeGroupData_,
    reFreshTreeData
  }
}
